package com.sailorless.luna 
{
	import com.sailorless.luna.graphics.SpriteBitch;
	import com.sailorless.luna.graphics.Texture2D;
	import flash.display.BitmapData;
	import flash.display.Loader;
	import flash.display.Stage;
	import flash.events.Event;
	import flash.geom.Point;
	import flash.utils.getTimer;
	
	/**
	 * 这是一个位图引擎,采用CopyPixels纯位图渲染，适合大量real time渲染
	 * @author Herbs
	 */
	public class Luna 
	{
		protected var spriteBitch:SpriteBitch;
		private var gGameTime:GameTime;
		
		public function Luna() 
		{
			gGameTime = new GameTime();
		}
		
		/**
		 * This is the game loop call,  allows the game to run logic such as updating the world,
         * checking for collisions, gathering input, and playing audio.
		 */
		protected function update(gameTime:GameTime):void 
		{
			
		}
		
		
		public function initialize(stage:Stage, canvas:BitmapData):void 
		{
			spriteBitch = new SpriteBitch(canvas);
			stage.addEventListener(Event.ENTER_FRAME, onGameLoop);
		}
		
		private function onGameLoop(e:Event):void 
		{
			spriteBitch.clear();
			gGameTime.setRealTime(getTimer());
			update(gGameTime);
		}
		
	}

}